package ltd.flyweight.liquibasehelper.module.zngk.dao.entity;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.*;

@Data
@TableName(value = "sys_dict_type", autoResultMap = true)
public class ZngkSysDictTypeEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @TableId
    private String id;

    private String name;

    private Integer available;

    private String createBy;

    private Date createTime;

    private String updateBy;

    private Date updateTime;

    private String remark;

    @TableField(exist = false)
    private List<ZngkSysDictTypeExtensionEntity> extensionList;

    public Map<String, ZngkSysDictTypeExtensionEntity> getExtensionMapKeyWithDataKey() {
        return CollectionUtil.toMap(extensionList, new LinkedHashMap<>(), ZngkSysDictTypeExtensionEntity::getDataKey);
    }

    @TableField(exist = false)
    private List<ZngkSysDictDataEntity> dictDataList;

    public Map<Long, ZngkSysDictDataEntity> getDictDataMapKeyWithId() {
        return CollectionUtil.toMap(dictDataList, new LinkedHashMap<>(), ZngkSysDictDataEntity::getId);
    }

    public Map<String, ZngkSysDictDataEntity> getDictDataMapKeyWithValue() {
        return CollectionUtil.toMap(dictDataList, new LinkedHashMap<>(), ZngkSysDictDataEntity::getValue);
    }

}
